package cn.edu.scau.cmi.linjinyong.mybatis.dao;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import cn.edu.scau.cmi.linjinyong.mybatis.domain.Student;

public interface StudentDao {

	List<Student> listStudents();
	
	@Delete("delete from student where id = #{id}")
	boolean deleteStudentById(@Param("id")long id);
	
	@Select("select * from student where id = #{id}")
	Student getStudentById(@Param("id")long id);
	
	@Insert("insert into student (name, major) values (#{name}, #{major})")
	boolean addStudent(Student student);
	
	@Update("update student set name = #{name}, major = #{major} where id = #{id}")
	boolean updateStudent(Student student);
	
	@Update("update student set t_id = #{tid} where id = #{sid}")
	boolean chooseInstructor(@Param("sid")long sid, @Param("tid")long tid);
	
	
	@Update("update student set confirm = 1 where id = #{sid}")
	boolean chooseStudent(@Param("sid")long sid);

	List<Student> listSelectableStudentsByTid(long tid);
}
